From: Florian Müllner Date: Sat, 21 Feb 2015 08:59:24 +0000 (+0100) Subject: dateMenu: Update message indicator on queue changes X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~1681 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=880b240ecbec90825179faa933545d842dd04382;p=gnome-shell.git dateMenu: Update message indicator on queue changes The message indicator conveys that the message list contains unseen messages that will not be shown as banner. So its visibility depends on two factors: the number of unseen messages, and the number of messages waiting in the queue to be shown as banner. As we currently only update the visibility on changes to the former, the indicator is not always accurate - for instance sources notify count changes before passing on a notification to the message tray for display. To fix, add a signal to the message tray to notify when the queue changes and use it to update the indicator's visibility. https://bugzilla.gnome.org/show_bug.cgi?id=744880 --- diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index 55b360b31..a36da317b 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -231,6 +231,7 @@ const MessagesIndicator = new Lang.Class({ Main.messageTray.connect('source-added', Lang.bind(this, this._onSourceAdded)); Main.messageTray.connect('source-removed', Lang.bind(this, this._onSourceRemoved)); + Main.messageTray.connect('queue-changed', Lang.bind(this, this._updateCount)); let sources = Main.messageTray.getSources(); sources.forEach(Lang.bind(this, function(source) { this._onSourceAdded(null, source); })); diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index 345dede34..c66e7b9d2 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -1662,8 +1662,10 @@ const MessageTray = new Lang.Class({ } let index = this._notificationQueue.indexOf(notification); - if (index != -1) + if (index != -1) { this._notificationQueue.splice(index, 1); + this.emit('queue-changed'); + } }, _onNotify: function(source, notification) { @@ -1686,6 +1688,7 @@ const MessageTray = new Lang.Class({ this._notificationQueue.sort(function(notification1, notification2) { return (notification2.urgency - notification1.urgency); }); + this.emit('queue-changed'); } } this._updateState(); @@ -1806,10 +1809,15 @@ const MessageTray = new Lang.Class({ this._updatingState = true; // Filter out acknowledged notifications. + let changed = false; this._notificationQueue = this._notificationQueue.filter(function(n) { + changed = changed || n.acknowledged; return !n.acknowledged; }); + if (changed) + this.emit('queue-changed'); + let hasNotifications = Main.sessionMode.hasNotifications; if (this._notificationState == State.HIDDEN) { @@ -1881,6 +1889,7 @@ const MessageTray = new Lang.Class({ _showNotification: function() { this._notification = this._notificationQueue.shift(); + this.emit('queue-changed'); this._userActiveWhileNotificationShown = this.idleMonitor.get_idletime() <= IDLE_TIME; if (!this._userActiveWhileNotificationShown) {